package com.example.administrator.myokhttpmvp.utils;

import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;

/**
 * Created by lisg on 2016/6/16.
 */
public class ToastUtil {

    private static Toast toastUtil;

    /**
     * 弹出一个toast
     *
     * @param context 上下文对象
     * @param resId   msg
     */
    public static void show(Context context, int resId) {
        if (context == null) {
            return;
        }

        Toast.makeText(context, resId, Toast.LENGTH_SHORT).show();
    }

    /**
     * 弹出一个toast
     *
     * @param context 上下文对象
     * @param message msg
     */
    public static void show(Context context, String message) {
        if (TextUtils.isEmpty(message) || context == null) {
            return;
        }
        if (toastUtil != null) {
            toastUtil.cancel();
        }
        toastUtil = Toast.makeText(context, message, Toast.LENGTH_SHORT);
        toastUtil.show();
//            Toast.makeText(context, message==null?".":message, Toast.LENGTH_SHORT).show();
    }
}
